package com.whu;

import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;

public class Infobar extends HBox {
    private Label cursor; // 游标
    private Label editingTool; //编辑工具

    private static String DrawModeFormat = "当前模式： %s ";
    private static String CursorPosFormat = "游标位置: (%d, %d)";

    public Infobar(){

        this.editingTool = new Label();
        this.cursor = new Label();

        Pane spacer = new Pane();// 创建一个小面板，放infobar
        spacer.setMinSize(0, 0);
        spacer.setMaxSize(Double.MAX_VALUE, Double.MIN_VALUE);
        HBox.setHgrow(spacer, Priority.ALWAYS);

        this.getChildren().addAll(this.editingTool, spacer, this.cursor);
    }

    public void setDrawMode(int drawMode){
        if(drawMode == Simulation.ALIVE){
            this.editingTool.setText(String.format(DrawModeFormat, "绘画~"));
        }else if(drawMode == Simulation.DEAD){
            this.editingTool.setText(String.format(DrawModeFormat, "擦除~"));
        }
    }
    public void setCursorPos(int x, int y){
        this.cursor.setText(String.format(CursorPosFormat, x, y));

    }
}
